﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />
/// <reference path="../Scripts/c1ls-4.0.20141.30.js" />

if (typeof c1ls === "undefined") {
    window.location.href = "http://bit.ly/c1ls-nuget";
}

// http://bitly.com/c1ls-gallery
//
myapp.GalleryImageViewer.WijmoGallery_render = function (element, contentItem) {

    var div = $("<div style='height:600px'/>");
    div.appendTo($(element));

    contentItem.value.oncollectionchange = function () {
        var p = c1ls.getGalleryProperties(contentItem);

        if (p.image !== null) {
            var list = [];
            list.push("<ul>");

            contentItem.value.data.forEach(function (r) {
                list.push("<li><img width='200' height='150' src='" + p.src(r) + "' title='" + r[p.caption] + "'/></li>");
            });

            list.push("</ul>");
            div.html(list.join("\r\n"));
            div.wijgallery();
        }
    };

    c1ls.renderControl(contentItem);
};
